package com.ruoyi.yl.process.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.domain.Activity;
import com.ruoyi.system.api.constant.YlStatus;
import com.ruoyi.yl.process.ActivityProcess;
import com.ruoyi.common.domain.constant.to.MessageActivityTo;
import com.ruoyi.yl.service.IActivityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ActivityProcessImpl implements ActivityProcess {
    @Resource
    private IActivityService activityService;


    @Override

    public void increaseParticipateByActivityId(MessageActivityTo to) {
        Activity activity = activityService.getBaseMapper().selectOne(Wrappers.lambdaQuery(Activity.class)
                .eq(Activity::getId, to.getActivityId())
                .eq(Activity::getStatus, YlStatus.NORMAL.getCode())
        );
        activity.setCurrentParticipants(activity.getCurrentParticipants() + 1);
        activityService.updateById(activity);
    }
}
